<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$Think.config.site.title} - 版本管理</title>
    <meta name="keywords" content="{$Think.config.site.keywords}">
    <meta name="description" content="{$Think.config.site.description}">
    <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/iCheck/custom.css" rel="stylesheet">
     <!-- Data Tables -->
    <link href="{$Think.config.site.resource_url}css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/animate.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.css?v=4.1.0" rel="stylesheet">
</head>
<style>
    .fa{ color:#1ab394;  cursor:pointer;}
</style>
<body >
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
            <style type="text/css">.col-sm-12 label{ font-weight:300; }</style>
                <div class="ibox float-e-margins">
                    <div class="">
                        <h5>{:lang('版本管理')}</h5>
                    </div>
                    <div class="ibox-content">
                        <div class="row">
                            <button type="button" class="btn btn-sm btn-primary" id="addBtn"> {:lang('添加版本信息')}</button>
                        </div>
                        <table class="table table-hover" id="listtable">
                            <thead>
                                <tr>
                                    <th>{:lang('服务器地址类型')}</th>
                                    <th>{:lang('地址')}:</th>
                                    <th>{:lang('操作')}</th>
                                </tr>
                            </thead>
                            <tbody>
                            {volist name="list" id="v"}
                                <tr data-id="{$v.id}">
                                    <td>{if condition="$v['types'] eq 1 "} request {elseif condition="$v['types'] eq 2"} socket {elseif condition="$v['types'] eq 3"} uploadFile {elseif condition="$v['types'] eq 4"} downloadFile  {/if}</td>
                                    <td>{$v.addr}</td>
                                    <td><i class="fa fa-edit"> {:lang('操作')} </i>　<i class="fa fa-trash-o"> {:lang('删除')}</i></td>
                                </tr> 
                            {/volist}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 全局js -->
    <script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
    <script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.6"></script>
    <!-- Peity -->
    <script src="{$Think.config.site.resource_url}js/plugins/peity/jquery.peity.min.js"></script>
    <!-- 自定义js -->
    <script src="{$Think.config.site.resource_url}js/content.js?v=1.0.0"></script>
    <!-- iCheck -->
    <script src="{$Think.config.site.resource_url}js/plugins/iCheck/icheck.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>
    <script type="text/javascript">
        var layer_font;
        var $editTr;
        $(function(){
            //修改按钮
            $("#listtable").on("click",".fa-edit",function(){
                $editTr = $(this).closest("tr");
                var eid = $editTr.data("id");
                layer_font = layer.open({
                  type: 2,
                  title: "{:lang('更新服务器地址')}",
                  shadeClose: true,
                  shade: 0.8,
                  area: ['50%', '50%'],
                  content: '<?php echo \think\Request::instance()->root(); ?>/ausadmin/System/serviceaddr?eid='+eid //iframe的url
                });
            });
            $("#listtable").on("click",".fa-trash-o",function(){
                var $tr = $(this).closest("tr");
                var did = $tr.data("id");
                layer.confirm("{:lang('确定要删除？')}", {
                    btn: ["{:lang('确定删除')}","{:lang('不删除')}"], //按钮
                    shade: false //不显示遮罩
                }, function(){
                    //确定删除
                    $.ajax({
                        type : 'POST',//delete
                        url : '<?php echo \think\Request::instance()->root(); ?>/ausadmin/System/serviceaddr?did='+did,
                        dataType : 'json',
                        data : {did:did},
                        async:false,
                        success : function(result) {
                            //layer.close(layer1);
                            if(0 === result.code) {
                                $tr.remove();
                                layer.msg(result.msg, {icon: 1});
                            }  else  {
                                //删除失败
                                layer.msg(result.msg, {icon: 5});
                            }
                        },
                        error : function(){
                            res = false;
                            layer.msg("{:lang('服务器错误！请稍后重试')}", {icon: 2});
                        }
                    })
                },
                function(){
                    
                });  
            });

            $('#addBtn').click(function(){
                layer_font = layer.open({
                  type: 2,
                  title: "{:lang('添加服务器地址信息')}",
                  shadeClose: true,
                  shade: 0.8,
                  area: ['50%', '50%'],
                  content: '<?php echo \think\Request::instance()->root(); ?>/ausadmin/System/addservice' //iframe的url
                });
            });
        });
    </script>
</body>

</html>
